package jsen.tool.ddd.adapter.infrastructure.specification.demo.spec.line;

import jsen.tool.ddd.adapter.infrastructure.specification.ISpecification;
import jsen.tool.ddd.adapter.infrastructure.specification.base.SpecContext;
import jsen.tool.ddd.adapter.infrastructure.specification.demo.Line;

/**
 * @author jsen
 * @date 2021/10/6
 */
public class LineSpec implements ISpecification<Line> {
    @Override
    public boolean isSatisfiedBy(SpecContext<Line> t) {
        Integer w = t.getData().getWidth();
        boolean wValid = w != null && w > 99;
        if (!wValid) {
            t.addError("LineSpec", "width必须大于99");
        }
        return wValid;
    }

}
